package com.bookocean.infrastructure.persistence.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.bookocean.infrastructure.persistence.po.RewardDefinitionPO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 奖励定义 Mapper 接口
 * 
 * @author BookOcean
 * @since 2024-01-01
 */
@Mapper
public interface RewardDefinitionMapper extends BaseMapper<RewardDefinitionPO> {

    /**
     * 查询所有启用的奖励定义
     * 
     * @return 奖励定义列表
     */
    @Select("SELECT * FROM reward_definition_po WHERE is_active = 1 ORDER BY points_cost ASC")
    List<RewardDefinitionPO> selectActiveRewards();

    /**
     * 根据类型查询奖励定义
     * 
     * @param type 奖励类型
     * @return 奖励定义列表
     */
    @Select("SELECT * FROM reward_definition_po WHERE type = #{type} AND is_active = 1 ORDER BY points_cost ASC")
    List<RewardDefinitionPO> selectRewardsByType(@Param("type") String type);

    /**
     * 根据积分范围查询奖励定义
     * 
     * @param minPoints 最小积分
     * @param maxPoints 最大积分
     * @return 奖励定义列表
     */
    @Select("SELECT * FROM reward_definition_po WHERE points_cost BETWEEN #{minPoints} AND #{maxPoints} AND is_active = 1 ORDER BY points_cost ASC")
    List<RewardDefinitionPO> selectRewardsByPointsRange(@Param("minPoints") Integer minPoints, 
                                                        @Param("maxPoints") Integer maxPoints);
}
